feat: JSON Schema support + generator drift detection (LED-713)#2
Merged
feat: JSON Schema support + generator drift detection (LED-713)#2
Conversation
Guards against None schemas in _compare_schema_deep, found during Directus (34K stars) showcase run. Also adds null guards at top of diff() method. 128 tests pass. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds first-class JSON Schema support to delimit-action so it can run governance checks against schema files like agents-oss/agentspec's agent.schema.json (issue #21). Changes: - core/json_schema_diff.py — new sibling module to diff_engine_v2. Handles Draft 4+ single-file schemas with internal $ref resolution to #/definitions. Covers 12 v1 change types: property add/remove, required add/remove, type widen/narrow, enum add/remove, const, additionalProperties, pattern, minLength/maxLength, minimum/maximum, items type. Composition keywords (anyOf/oneOf/ allOf) and external $ref deferred past v1. - core/generator_drift.py — new module that runs a regen command in a sandbox and diffs the regenerated artifact against the committed version. Catches drift between source-of-truth (e.g. Zod) and committed generated artifacts. Restores the workspace cleanly so the working tree is unmodified after the check. - core/spec_detector.py — added detect_spec_type() classifier and get_diff_engine() factory. Routes JSON Schema files to the new engine; OpenAPI files keep the existing path. Back-compat: ambiguous docs default to OpenAPI. - action.yml — three new inputs: - fail_on_breaking (boolean alias for mode=enforce) - generator_command (opt-in drift check) - generator_artifact (paired with generator_command) Plus dispatch logic in the validate step and a new JSON Schema branch in the Comment-on-PR step that renders drift + classification. - tests/test_json_schema_diff.py — 41 unit tests covering every v1 change type, $ref resolution at root and nested paths, dispatcher routing, and the agentspec rename as a real-world fixture. Test results: - 41/41 new JSON Schema tests pass - 47/47 existing OpenAPI diff_engine tests still pass (no regressions) Verified end-to-end against the agents-oss/agentspec checkout with the real pnpm run schema:export generator. All three scenarios (clean main, simulated rename PR, hypothetical version bump) classify correctly with expected output. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The previous header rendered "0 change(s), 1 breaking" when the committed schema was unchanged but generator drift was detected. Suppress the schema-classification line entirely when the diff is empty, and surface drift as a separate "Generator drift: N change(s), N breaking" line so the two signals never appear comma-joined. Caught by deliberation on the live infracore/agentspec#1 test run. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
crypttrx
approved these changes
Apr 7, 2026
Contributor
crypttrx
left a comment
There was a problem hiding this comment.
Approving per consensus deliberation + founder approval in chat. 88/88 unit tests passing. Smoke test failures are pre-existing and unrelated.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
core/json_schema_diff.pysibling modulecore/generator_drift.py) for catching staleness between source-of-truth (Zod, protobuf, etc.) and committed generated artifactsfail_on_breaking,generator_command,generator_artifactaction inputsWhy
Validating delimit-action against agents-oss/agentspec#21 (maintainer invited integration) revealed the diff engine returned
0 changeson bare JSON Schema files. This release closes the gap before the agentspec PR opens.Test plan
tests/test_json_schema_diff.py— all passingpnpm run schema:exportScope (v1)
Property add/remove, required add/remove, type widen/narrow, enum add/remove, const, additionalProperties, pattern, minLength/maxLength, minimum/maximum, items type.
$refto#/definitionsresolved at root and nested. Composition keywords (anyOf/oneOf/allOf), discriminators, external$ref, andif/then/elsedeferred past v1.🤖 Generated with Claude Code